package com.yimi.yinhepda.adapter.RecycleAdapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.CheckBox;

import com.yimi.yinhepda.R;
import com.pda.ym.base.CommonRecycleAdapter;
import com.pda.ym.base.CommonViewHolder;
import com.yimi.yinhepda.db.table.FuncBtnTable;

import java.util.List;

/**
 * @author: lj
 * Date: 2019/10/10 11:06
 * Description:功能编辑适配器
 */
public class FuncBtnEditAdapter extends CommonRecycleAdapter<FuncBtnTable> {

    private Context mContext;
    private CommonViewHolder.onItemCommonClickListener mCommonClickListener;

    public FuncBtnEditAdapter(Context context, List<FuncBtnTable> dataList, CommonViewHolder.onItemCommonClickListener commonClickListener) {
        super(context, dataList, R.layout.adapter_func_btn_edit_item);
        this.mContext = context;
        this.mCommonClickListener = commonClickListener;
    }

    @Override
    public void bindData(CommonViewHolder holder, FuncBtnTable data, int position) {
        holder.setCommonClickListener(mCommonClickListener);
        holder.setImageResource(R.id.iv_func_pic,data.getPicId());
        holder.setText(R.id.tv_func_name, data.getName());
        CheckBox checkBox = holder.getView(R.id.cb_select);
        Drawable mDrawable = mContext.getResources().getDrawable(R.drawable.check_box_custom_selecter);
        mDrawable.setBounds(0, 0, 30, 30);
        checkBox.setCompoundDrawables(mDrawable, null, null, null);
        checkBox.setChecked(data.getIsCommUse() == 1);
    }
}
